package com.bite.system.controller.exam;

import com.bite.common.core.controller.BaseController;
import com.bite.common.core.domain.R;
import com.bite.common.core.domain.TableDataInfo;
import com.bite.system.domain.exam.ExamQuestion;
import com.bite.system.domain.exam.dto.ExamAddDTO;
import com.bite.system.domain.exam.dto.ExamEditDTO;
import com.bite.system.domain.exam.dto.ExamQueryDto;
import com.bite.system.domain.exam.dto.ExamQuestionAddDTO;
import com.bite.system.domain.exam.vo.ExamDetailVO;
import com.bite.system.service.exam.IExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/exam")
public class ExamController extends BaseController {
    @Autowired
    private IExamService examService;
    //exam/list
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDto examQueryDto){
        return   getTableDataInfo( examService.list(examQueryDto));
    }
    @PostMapping("/add")
    public R<String> add(@RequestBody ExamAddDTO examAddDto){
        return R.ok(examService.add(examAddDto));
    }
    @PostMapping("/question/add")
    public R<Void> questionAdd(@RequestBody ExamQuestionAddDTO examQuestionAddDTO){
        return toR(examService.questionAdd(examQuestionAddDTO));
    }
    @GetMapping("/detail")
    public R<ExamDetailVO>  detail(Long examId){
     return R.ok(examService.detail(examId));
    }
    @PutMapping("/edit")
    public R<Void> edit(@RequestBody ExamEditDTO examEditDTO){
        return toR(examService.edit(examEditDTO));
    }
    @DeleteMapping("question/delete")
    public R<Void> questionDelete(Long examId,Long questionId){
        return toR(examService.questionDelete(examId,questionId));
    }
    @DeleteMapping("delete")
    public R<Void> delete(Long examId){
        return toR(examService.delete(examId));
    }
    @PutMapping("/publish")
    public R<Void> publish(Long examId){
        return toR(examService.publish(examId));
    }
    @PutMapping("/cancelPublish")
    public R<Void> cancelPublish(Long examId){
        return toR(examService.cancelPublish(examId));
    }

}
